package com.notepad.util;

import java.util.Calendar;


public class SpecialCalendar {
	private int daysOfMonth; //每个月的天数
	private int dayOfWeek;   //某一天是星期几
	
	public boolean isLeapYear(int year){
		if(year % 100 == 0 && year % 400 == 0){
			return true;
		}else if(year % 100 != 0 && year % 4 ==0){
			return true;
		}
		return false;
	}
	
	public int getDaysOfMonth(boolean isLeapYear,int month){
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			daysOfMonth = 31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			daysOfMonth = 30;
			break;
		case 2:
			if(isLeapYear){
				daysOfMonth = 29;
			}else{
				daysOfMonth = 28;
			}
			break;
		}
		return daysOfMonth;
	}
	
	
	//指定某年中的某月的第一天是星期几		
		public int getWeekdayOfMonth(int year,int month){
			Calendar cal = Calendar.getInstance();
			cal.set(year, month-1, 1);
			dayOfWeek = cal.get(Calendar.DAY_OF_WEEK)-1;
			return dayOfWeek;
			
		}
	
}
